package bao;

import java.io.IOException;


import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class Zq
 */
@WebServlet("/Zq")
public class Zq extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public Zq() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		
		try {request.setCharacterEncoding("UTF-8");
		response.setContentType("text/html;charset=UTF-8");
			Class.forName("com.mysql.cj.jdbc.Driver");
			Connection con = (Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/yj?autoReconnect=true&serverTimezone=GMT","root","root");
			
			PreparedStatement j=con.prepareStatement("insert into zq(site_j,uid,goods,time,site_w,count,zq_message,flag) values(?,?,?,?,?,?,?,0)");
			j.setString(1,  request.getParameter("site_j").toString());
			j.setString(2,  request.getParameter("uid").toString());
			j.setString(3,  request.getParameter("goods").toString());
			j.setString(4,  request.getParameter("time").toString());
			j.setString(5,  request.getParameter("site_w").toString());
			j.setString(6,  request.getParameter("count").toString());
			j.setString(7,  request.getParameter("zq_message").toString());
			int w=j.executeUpdate();
			
			j.close();
			con.close();
			response.sendRedirect("start.jsp");
					
			
	}catch (Exception e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
